clear all
set more off
cd "/homes/nber/yasenov"

use "~/matched_30_40_ready.dta"

label var dmex " $MexPopDrop\_c$ "

********************
*** REGRESSIONS ****
********************
global ind_controls age_A married_A black literate_A c.age_A#c.age_A c.age_A#i.black c.age_A#i.married_A i.black#i.married_A c.age_A#i.literate_A i.literate_A#i.black i.literate_A#i.married
global cnty_controls lnpop30 s_young s_agric s_mf s_urban s_illiterate dustbowl extreme_phdi pop_dens
global more_controls $cnty_controls rldf3329 c.rldf3329#c.rldf3329 miles_to_mex c.miles_to_mex#c.miles_to_mex c.miles_to_mex#c.rldf3329 aa relief loan death_rate rldf3933 c.rldf3933#c.rldf3933

global options cluster(county) absorb(statefip_A)

***************
***************
***************


******************** TABLE 1: MAIN *******************
eststo clear

eststo: ivreghdfe dempl $ind_controls $more_controls (dmex = mex_share10) if low_skilled == 1, $options
qui estadd ysumm
eststo: ivreghdfe dempl $ind_controls $more_controls rail2 (dmex = rail_interact) if low_skilled == 1, $options
qui estadd ysumm
eststo: ivreghdfe dempl $ind_controls $more_controls close_to_rr (dmex = close_to_rr_interact) if low_skilled == 1, $options
qui estadd ysumm


eststo: ivreghdfe dempl $ind_controls $more_controls (dmex = mex_share10) if high_skilled == 1, $options
qui estadd ysumm
eststo: ivreghdfe dempl $ind_controls $more_controls rail2 (dmex = rail_interact) if high_skilled == 1, $options
qui estadd ysumm
eststo: ivreghdfe dempl $ind_controls $more_controls close_to_rr (dmex = close_to_rr_interact) if high_skilled == 1, $options
qui estadd ysumm

esttab using "~/by_skill.tex", ///
	keep(dmex) ///
	replace se(3) b(3) stats(N ymean, labels("N" "$\bar{Y}$") fmt(0 3)) star(* 0.10 ** 0.05 *** 0.01) nonum nonotes noconstant nogaps label ///
	mtitles("(1)" "(2)" "(3)" "(4)" "(5)" "(6)") /// 
	prehead("{\def\sym#1{\ifmmode^{#1}\else\(^{#1}\)\fi}\begin{tabular}{l*{6}{c}}\hline\hline & \multicolumn{6}{c}{\textbf{Panel A: $\Delta$ Employment 1930-1940}} \\\cmidrule(lr){2-7} & \multicolumn{3}{c}{Low Skilled} & \multicolumn{3}{c}{High Skilled} \\  \cmidrule(lr){2-4}  \cmidrule(lr){5-7} %") ///
	postfoot("")

eststo clear	
eststo: ivreghdfe dempl_1 $ind_controls $more_controls (dmex = mex_share10) if low_skilled == 1, $options
qui estadd ysumm
eststo: ivreghdfe dempl_1 $ind_controls $more_controls rail2 (dmex = rail_interact) if low_skilled == 1, $options
qui estadd ysumm
eststo: ivreghdfe dempl_1 $ind_controls $more_controls close_to_rr (dmex = close_to_rr_interact) if low_skilled == 1, $options
qui estadd ysumm

eststo: ivreghdfe dempl_1 $ind_controls $more_controls (dmex = mex_share10) if high_skilled == 1, $options
qui estadd ysumm
eststo: ivreghdfe dempl_1 $ind_controls $more_controls rail2 (dmex = rail_interact) if high_skilled == 1, $options
qui estadd ysumm
eststo: ivreghdfe dempl_1 $ind_controls $more_controls close_to_rr (dmex = close_to_rr_interact) if high_skilled == 1, $options
qui estadd ysumm

esttab using "~/by_skill.tex", ///
	keep(dmex) ///
	append se(3) b(3) stats(N ymean, labels("N" "$\bar{Y}$") fmt(0 3)) star(* 0.10 ** 0.05 *** 0.01) nonum nonotes noconstant nogaps label ///
	mtitles("(1)" "(2)" "(3)" "(4)" "(5)" "(6)") /// 
	prehead("\\ & \multicolumn{6}{c}{\textbf{Panel B: Non-Employed 1930 $\rightarrow$ Employed 1940}} \\\cmidrule(lr){2-7} & \multicolumn{3}{c}{Low Skilled} & \multicolumn{3}{c}{High Skilled} \\  \cmidrule(lr){2-4}  \cmidrule(lr){5-7} %") ///
	postfoot("")

eststo clear	
eststo: ivreghdfe dwage $ind_controls $more_controls (dmex = mex_share10) if low_skilled == 1, $options
qui estadd ysumm
eststo: ivreghdfe dwage $ind_controls $more_controls rail2 (dmex = rail_interact) if low_skilled == 1, $options
qui estadd ysumm
eststo: ivreghdfe dwage $ind_controls $more_controls close_to_rr (dmex = close_to_rr_interact) if low_skilled == 1, $options
qui estadd ysumm

eststo: ivreghdfe dwage $ind_controls $more_controls (dmex = mex_share10) if high_skilled == 1, $options
qui estadd ysumm
eststo: ivreghdfe dwage $ind_controls $more_controls rail2 (dmex = rail_interact) if high_skilled == 1, $options
qui estadd ysumm
eststo: ivreghdfe dwage $ind_controls $more_controls close_to_rr (dmex = close_to_rr_interact) if high_skilled == 1, $options
qui estadd ysumm

esttab using "~/by_skill.tex", ///
	keep(dmex) ///
	append se(3) b(3) stats(N ymean, labels("N" "$\bar{Y}$") fmt(0 3)) star(* 0.10 ** 0.05 *** 0.01) nonum nonotes noconstant nogaps label ///
	mtitles("(1)" "(2)" "(3)" "(4)" "(5)" "(6)") /// 
	prehead("\\ & \multicolumn{6}{c}{\textbf{Panel C: $\Delta$ Occupational Wage 1930-1940}} \\\cmidrule(lr){2-7}  & \multicolumn{3}{c}{Low Skilled} & \multicolumn{3}{c}{High Skilled} \\  \cmidrule(lr){2-4}  \cmidrule(lr){5-7} %") ///
	postfoot("")

eststo clear
eststo: ivreghdfe stayer $ind_controls $more_controls (dmex = mex_share10) if low_skilled == 1, $options
estadd local bslncntrl "X"
estadd local morecntrls "X" 
estadd local ols ""
estadd local iv1 "X"
estadd local iv3 ""
estadd local iv4 ""
estadd local iv5 ""
qui estadd ysumm
eststo: ivreghdfe stayer $ind_controls $more_controls rail2 (dmex = rail_interact) if low_skilled == 1, $options
estadd local bslncntrl "X"
estadd local morecntrls "X" 
estadd local ols ""
estadd local iv1 ""
estadd local iv3 "X"
estadd local iv4 ""
estadd local iv5 ""
qui estadd ysumm
eststo: ivreghdfe stayer $ind_controls $more_controls close_to_rr (dmex = close_to_rr_interact) if low_skilled == 1, $options
estadd local bslncntrl "X"
estadd local morecntrls "X" 
estadd local ols ""
estadd local iv1 ""
estadd local iv3 ""
estadd local iv4 "X"
estadd local iv5 ""
qui estadd ysumm

eststo: ivreghdfe stayer $ind_controls $more_controls (dmex = mex_share10) if high_skilled == 1, $options
estadd local bslncntrl "X"
estadd local morecntrls "X" 
estadd local ols ""
estadd local iv1 "X"
estadd local iv3 ""
estadd local iv4 ""
estadd local iv5 ""
qui estadd ysumm
eststo: ivreghdfe stayer $ind_controls $more_controls rail2 (dmex = rail_interact) if high_skilled == 1, $options
estadd local bslncntrl "X"
estadd local morecntrls "X" 
estadd local ols ""
estadd local iv1 ""
estadd local iv3 "X"
estadd local iv4 ""
estadd local iv5 ""
qui estadd ysumm
eststo: ivreghdfe stayer $ind_controls $more_controls close_to_rr (dmex = close_to_rr_interact) if high_skilled == 1, $options
estadd local bslncntrl "X"
estadd local morecntrls "X" 
estadd local ols ""
estadd local iv1 ""
estadd local iv3 ""
estadd local iv4 "X"
estadd local iv5 ""
qui estadd ysumm

esttab using "~/by_skill.tex", ///
	keep(dmex) ///
	append se(3) b(3) stats(N ymean bslncntrl morecntrls ols iv1 iv3 iv4, labels("N" "$\bar{Y}$" "Baseline Controls" "Full Controls" "OLS" "Enclave IV" "Railroad IV" "Close to RR IV" ) fmt(0 3)) star(* 0.10 ** 0.05 *** 0.01) nonum nonotes noconstant nogaps label ///
	mtitles("(1)" "(2)" "(3)" "(4)" "(5)" "(6)") /// 
	prehead("\\ & \multicolumn{6}{c}{\textbf{Panel D: Same State 1930-1935}} \\\cmidrule(lr){2-7} & \multicolumn{3}{c}{Low Skilled} & \multicolumn{3}{c}{High Skilled} \\  \cmidrule(lr){2-4}  \cmidrule(lr){5-7} %")
 
   
******************** TABLE 2: APPENDIX *******************
eststo clear

eststo: ivreghdfe dself $ind_controls $more_controls (dmex = mex_share10) if low_skilled == 1, $options
qui estadd ysumm
eststo: ivreghdfe dself $ind_controls $more_controls rail2 (dmex = rail_interact) if low_skilled == 1, $options
qui estadd ysumm
eststo: ivreghdfe dself $ind_controls $more_controls close_to_rr (dmex = close_to_rr_interact) if low_skilled == 1, $options
qui estadd ysumm

eststo: ivreghdfe dself $ind_controls $more_controls (dmex = mex_share10) if high_skilled == 1, $options
qui estadd ysumm
eststo: ivreghdfe dself $ind_controls $more_controls rail2 (dmex = rail_interact) if high_skilled == 1, $options
qui estadd ysumm
eststo: ivreghdfe dself $ind_controls $more_controls close_to_rr (dmex = close_to_rr_interact) if high_skilled == 1, $options
qui estadd ysumm

esttab using "~/by_skill_appendix.tex", ///
	keep(dmex) ///
	replace se(3) b(3) stats(N ymean, labels("N" "$\bar{Y}$") fmt(0 3)) star(* 0.10 ** 0.05 *** 0.01) nonum nonotes noconstant nogaps label ///
	mtitles("(1)" "(2)" "(3)" "(4)" "(5)" "(6)") /// 
	prehead("{\def\sym#1{\ifmmode^{#1}\else\(^{#1}\)\fi}\begin{tabular}{l*{8}{c}}\hline\hline \\ & \multicolumn{6}{c}{\textbf{Panel A: $\Delta$ Self-Employment 1930-1940}} \\\cmidrule(lr){2-7} & \multicolumn{3}{c}{Low Skilled} & \multicolumn{3}{c}{High Skilled} \\  \cmidrule(lr){2-4}  \cmidrule(lr){5-7} %") ///
	postfoot("")

eststo clear	
eststo: ivreghdfe doccscore $ind_controls $more_controls (dmex = mex_share10) if low_skilled == 1, $options
qui estadd ysumm
eststo: ivreghdfe doccscore $ind_controls $more_controls rail2 (dmex = rail_interact) if low_skilled == 1, $options
qui estadd ysumm
eststo: ivreghdfe doccscore $ind_controls $more_controls close_to_rr (dmex = close_to_rr_interact) if low_skilled == 1, $options
qui estadd ysumm

eststo: ivreghdfe doccscore $ind_controls $more_controls (dmex = mex_share10) if high_skilled == 1, $options
qui estadd ysumm
eststo: ivreghdfe doccscore $ind_controls $more_controls rail2 (dmex = rail_interact) if high_skilled == 1, $options
qui estadd ysumm
eststo: ivreghdfe doccscore $ind_controls $more_controls close_to_rr (dmex = close_to_rr_interact) if high_skilled == 1, $options
qui estadd ysumm

esttab using "~/by_skill_appendix.tex", ///
	keep(dmex) ///
	append se(3) b(3) stats(N ymean, labels("N" "$\bar{Y}$") fmt(0 3)) star(* 0.10 ** 0.05 *** 0.01) nonum nonotes noconstant nogaps label ///
	mtitles("(1)" "(2)" "(3)" "(4)" "(5)" "(6)") /// 
	prehead("\\ & \multicolumn{6}{c}{\textbf{Panel B: $\Delta$ Occupational Score 1930-1940}} \\\cmidrule(lr){2-7} & \multicolumn{3}{c}{Low Skilled} & \multicolumn{3}{c}{High Skilled} \\  \cmidrule(lr){2-4}  \cmidrule(lr){5-7} %") ///
	postfoot("")

eststo clear	
eststo: ivreghdfe stayer2 $ind_controls $more_controls (dmex = mex_share10) if low_skilled == 1, $options
qui estadd ysumm
eststo: ivreghdfe stayer2 $ind_controls $more_controls rail2 (dmex = rail_interact) if low_skilled == 1, $options
qui estadd ysumm
eststo: ivreghdfe stayer2 $ind_controls $more_controls close_to_rr (dmex = close_to_rr_interact) if low_skilled == 1, $options
qui estadd ysumm

eststo: ivreghdfe stayer2 $ind_controls $more_controls (dmex = mex_share10) if high_skilled == 1, $options
qui estadd ysumm
eststo: ivreghdfe stayer2 $ind_controls $more_controls rail2 (dmex = rail_interact) if high_skilled == 1, $options
qui estadd ysumm
eststo: ivreghdfe stayer2 $ind_controls $more_controls close_to_rr (dmex = close_to_rr_interact) if high_skilled == 1, $options
qui estadd ysumm

esttab using "~/by_skill_appendix.tex", ///
	keep(dmex) ///
	append se(3) b(3) stats(N ymean, labels("N" "$\bar{Y}$") fmt(0 3)) star(* 0.10 ** 0.05 *** 0.01) nonum nonotes noconstant nogaps label ///
	mtitles("(1)" "(2)" "(3)" "(4)" "(5)" "(6)") /// 
	prehead("\\ & \multicolumn{6}{c}{\textbf{Panel C: Same State 1930-1940}} \\\cmidrule(lr){2-7}  & \multicolumn{3}{c}{Low Skilled} & \multicolumn{3}{c}{High Skilled} \\  \cmidrule(lr){2-4}  \cmidrule(lr){5-7} %") ///
	postfoot("")

eststo clear
eststo: ivreghdfe drural_2 $ind_controls $more_controls (dmex = mex_share10) if low_skilled == 1, $options
estadd local bslncntrl "X"
estadd local morecntrls "X" 
estadd local ols ""
estadd local iv1 "X"
estadd local iv3 ""
estadd local iv4 ""
estadd local iv5 ""
qui estadd ysumm
eststo: ivreghdfe drural_2 $ind_controls $more_controls rail2 (dmex = rail_interact) if low_skilled == 1, $options
estadd local bslncntrl "X"
estadd local morecntrls "X" 
estadd local ols ""
estadd local iv1 ""
estadd local iv3 "X"
estadd local iv4 ""
estadd local iv5 ""
qui estadd ysumm
eststo: ivreghdfe drural_2 $ind_controls $more_controls close_to_rr (dmex = close_to_rr_interact) if low_skilled == 1, $options
estadd local bslncntrl "X"
estadd local morecntrls "X" 
estadd local ols ""
estadd local iv1 ""
estadd local iv3 ""
estadd local iv4 "X"
estadd local iv5 ""
qui estadd ysumm
eststo: ivreghdfe drural_2 $ind_controls $more_controls (dmex = mex_share10) if high_skilled == 1, $options
estadd local bslncntrl "X"
estadd local morecntrls "X" 
estadd local ols ""
estadd local iv1 "X"
estadd local iv3 ""
estadd local iv4 ""
estadd local iv5 ""
qui estadd ysumm
eststo: ivreghdfe drural_2 $ind_controls $more_controls rail2 (dmex = rail_interact) if high_skilled == 1, $options
estadd local bslncntrl "X"
estadd local morecntrls "X" 
estadd local ols ""
estadd local iv1 ""
estadd local iv3 "X"
estadd local iv4 ""
estadd local iv5 ""
qui estadd ysumm
eststo: ivreghdfe drural_2 $ind_controls $more_controls close_to_rr (dmex = close_to_rr_interact) if high_skilled == 1, $options
estadd local bslncntrl "X"
estadd local morecntrls "X" 
estadd local ols ""
estadd local iv1 ""
estadd local iv3 ""
estadd local iv4 "X"
estadd local iv5 ""
qui estadd ysumm

esttab using "~/by_skill_appendix.tex", ///
	keep(dmex) ///
	append se(3) b(3) stats(N ymean bslncntrl morecntrls ols iv1 iv3 iv4, labels("N" "$\bar{Y}$" "Baseline Controls" "Full Controls" "OLS" "Enclave IV" "Railroad IV" "Close to RR IV" ) fmt(0 3)) star(* 0.10 ** 0.05 *** 0.01) nonum nonotes noconstant nogaps label ///
	mtitles("(1)" "(2)" "(3)" "(4)" "(5)" "(6)") /// 
	prehead("\\ & \multicolumn{6}{c}{\textbf{Panel D: Rural 1930 $\rightarrow$ Urban 1940}} \\\cmidrule(lr){2-7} & \multicolumn{3}{c}{Low Skilled} & \multicolumn{3}{c}{High Skilled} \\  \cmidrule(lr){2-4}  \cmidrule(lr){5-7} %")
 
